Repository navigation
Protect only the tests of the rules for compiled code, not all of _compilation_test.py - #911
Merged
Merged
Conversation
…mpilation_test.py Move the five tests that enforce the code standard's rules for compiled functions, the test of their helper, and their helpers to a new file, _compiled_code_rules_test.py, which replaces _compilation_test.py in the list of protected files in AGENTS.md. code.rst and the distance README cite the new file. _compilation_test.py keeps the tests of what _compilation.py and the compiled-run options do. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
AGENTS.mdprotects the tests that enforce the standards, and those protected files change only through a patch that a maintainer approves. It listed all of_compilation_test.py, becausecode.rstsays that file enforces the rules for Numba code. But only five of its 33 tests enforce rules: they read the source and check how compiled functions are declared, called, imported, and placed. The rest test what_compilation.pydoes (the disk cache, the source hash, the registry of compiled-on-request functions, and the switch to plain Python) and the pytest options of the compiled runs. So routine compilation work needed an approved patch to change its tests; seven pull requests (#821 to #908) changed this file in the nine days after #768 protected it.Changes
The five rule tests, the test of their helper, and their helpers move unchanged, except for docstrings, to a new file,
src/qldpc/_compiled_code_rules_test.py. It replaces_compilation_test.pyin the list of protected files inAGENTS.md, andcode.rstand the distance README now cite it._compilation_test.pykeeps the tests of behavior, including the test that the compiled runs select the right test files, which mainly testsconftest.py. The new file's docstring notes that this unprotected test also catches a module whose only compiled functions use neither decorator. Each file now builds its own program that imports every module of qLDPC, so neither test file imports the other.The rules for working on qLDPC keep the same length, since one file name replaces another, and no rule is replaced; only which tests are protected changes.
Validation
Two independent reviewers compared four options: keep all of
_compilation_test.pyprotected, move the rule tests into_code_style_test.py, move them into a new protected file, or stop protecting them. Both chose a new file, since_code_style_test.pycovers module layout. The moved tests are line-for-line copies apart from docstrings, and the compiled runs select the same test files as before.